home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / prog / lzw4c12.zip / LZW4C.DOC < prev    next >
Text File  |  1993-02-28  |  36KB  |  961 lines

  1.  
  2.  
  3.                           LZW Data Compression Library
  4.  
  5.                                 For the C Language
  6.  
  7.  
  8.                                     (LZW4C)
  9.  
  10.  
  11.  
  12.                                  USERS MANUAL
  13.  
  14.  
  15.  
  16.  
  17.  
  18.                                   Version 1.2
  19.  
  20.                                  March 1, 1993
  21.  
  22.  
  23.  
  24.  
  25.                         This software is provided as-is.
  26.                  There are no warranties, expressed or implied.
  27.  
  28.  
  29.  
  30.  
  31.                               Copyright (C) 1993
  32.                               All rights reserved
  33.  
  34.  
  35.  
  36.                               MarshallSoft Computing, Inc.
  37.                               Post Office Box 4543
  38.                               Huntsville AL 35815
  39.  
  40.                               205-881-4630 Voice / FAX
  41.                               205-880-9748 Support BBS
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.         LZW4C Users Manual                                     Page 1
  61.                               C O N T E N T S
  62.  
  63.  
  64.  
  65.  
  66.  
  67.          Chapter                                                   Page
  68.  
  69.          1.0 Introduction..............................................3
  70.              1.1 Distribution Files....................................3
  71.              1.2 Compiling the Library.................................4
  72.              1.3 User Support..........................................4
  73.              1.4 Installation..........................................5
  74.          2.0 The LZW Algorithm.........................................6
  75.              2.1 LZW Compression.......................................6
  76.              2.2 LZW Expansion.........................................7
  77.              2.3 LZW Implementation....................................7
  78.          3.0 Example Programs..........................................8
  79.              3.1 COMPRESS..............................................8
  80.              3.2 EXPAND................................................8
  81.              3.3 TEST_LZW..............................................9
  82.              3.4 MK_ARC................................................9
  83.              3.5 UN_ARC................................................9
  84.              3.6 SEE_ARC...............................................9
  85.          4.0 Reader & Writer Functions................................10
  86.          5.0 Library Functions........................................11
  87.              5.1 InitLZW..............................................11
  88.              5.2 TermLZW..............................................11
  89.              5.3 Compress.............................................12
  90.              5.4 Expand...............................................12
  91.          6.0 Error Codes..............................................13
  92.              6.1 EXPANSION_ERROR......................................13
  93.              6.2 CANNOT_ALLOCATE......................................13
  94.              6.3 INTERNAL_ERROR.......................................13
  95.              6.4 NOT_READY............................................13
  96.          7.0 Legal Issues.............................................14
  97.              7.1 Registration.........................................14
  98.              7.2 License..............................................15
  99.              7.3 Warranty.............................................15
  100.          8.0 Revision History.........................................15
  101.          9.0 Other MarshallSoft Computing Products for C..............16
  102.              9.1 The Personal Communications Library for C............16
  103.              9.2 The Personal Protocol Library for C..................16
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.         LZW4C Users Manual                                     Page 2
  121.          1.0 Introduction
  122.  
  123.  
  124.          LZW4C  consists  of a variable code size implementation of the LZW
  125.          (Lempel-Ziv-Welch) algorithm  for  compressing  and  decompressing
  126.          data.   LZW does particularly well on text files, achieving better
  127.          than a 50 % compression ratio for many files.
  128.  
  129.          The  LZW  algorithm  is  considered  to be one of the best general
  130.          purpose algorithms available today.  The  new  high  speed  modems
  131.          that  employ  on-the-fly  data  compression (such as MNP 5.0 & the
  132.          V.42 bis international standard) use the LZW  algorithm,  as  well
  133.          as such well known utility programs such as PKZIP.
  134.  
  135.          The  LZW4C  library  is  designed  to be used in a wide variety of
  136.          situations. Some of the possible uses include:
  137.  
  138.          1) Compression and expanding files on disk.
  139.          2) Compressing files "on the fly" before  sending  over  a  modem,
  140.             and then expanding on the receiving end.
  141.          3) Compression of data files used by your application program such
  142.             as help files, graphics screens, etc. The compressed data files
  143.             are then expanded as they are loaded by the application.
  144.  
  145.  
  146.          1.1 Distribution Files
  147.  
  148.          The distribution files are as follows:
  149.  
  150.           1) LZW4C_C.LIB -- COMPACT model library.
  151.           2) LZW4C_L.LIB -- LARGE model library.
  152.           3) LZW4C_L.MIX -- LARGE model library (MIX only).
  153.           4) LZW4C.DOC   -- This documentation file.
  154.           5) LZW4C.INV   -- Invoice file.
  155.           6) COMPRESS.C  -- Data compression example program.
  156.           7) EXPAND.C    -- Data expansion example program.
  157.           8) LZW4C.H     -- Library prototypes.
  158.           9) TEST_LZW.C  -- LZW test driver program.
  159.          10) MK_ARC.C    -- File archiving program.
  160.          11) UN_ARC.C    -- File un-archiving program.
  161.          12) SEE_ARC.C   -- Program to list archived files.
  162.          13) *._T_       -- Turbo C makefiles.
  163.          14) *._M_       -- Microsoft C makefiles.
  164.          15) X_*.BAT     -- MIX Power C batch file.
  165.          16) RW_IO.C     -- Reader/Writer I/O source file.
  166.          17) RW_IO.H     -- Reader/Writer prototype file.
  167.          18) DIR_IO.C    -- Directory I/O source file.
  168.          19) DIR_IO.H    -- Directory I/O prototype file.
  169.          20) SAYERROR.C  -- Displays text error messages.
  170.  
  171.          Registered users also receive:
  172.  
  173.           1) LZW4C.ASM   -- SOURCE CODE for the LZW4C libraries.
  174.           2) MAKE_C.BAT  -- Batch file to make LZW4C_C.LIB
  175.           3) MAKE_L.BAT  -- Batch file to make LZW4C_L.LIB
  176.           4) MAKE_XL.BAT -- Batch file to make LZW4C_L.MIX
  177.  
  178.  
  179.  
  180.         LZW4C Users Manual                                     Page 3
  181.          1.2 Compiling the Library
  182.  
  183.  
  184.          LZW4C  requires  rather  large  work  buffers  at  run time.  This
  185.          requires "far" data pointers which in turn  means  that  you  must
  186.          compile  using  either  the COMPACT memory model (with "near" code
  187.          pointers) or the LARGE memory model (with "far"  code  addresses).
  188.          There are, therefore, two memory model libraries provided:
  189.  
  190.          lzw4c_c.lib  -- Compact memory model library.
  191.          lzw4c_l.lib  -- Large memory model library.
  192.          lzw4c_l.mix  -- Large memory model library (MIX only).
  193.  
  194.          The registered user can re-compile the source code (source code is
  195.          provided in the registered version only) for the library using one
  196.          of the two provided batch files:
  197.  
  198.          make_c.bat  -- Creates lzw4c_c.lib.
  199.          make_l.bat  -- Creates lzw4c_l.lib.
  200.          make_xl.bat -- Create lzw4c_c.mix.
  201.  
  202.          Using  the  COMPACT memory model will result in a slightly smaller
  203.          and faster executable than using the LARGE memory model.  Be  sure
  204.          to compile all of your code for the correct memory model. Refer to
  205.          your compiler manual for more information on memory models.
  206.  
  207.  
  208.          1.3 User Support
  209.  
  210.          We  want you to be successful in developing your application using
  211.          our libraries! We depend on our customers to let us know what they
  212.          need in a library.  This means we are committed to  providing  the
  213.          best  libraries  that  we  can.   If  you  have any suggestions or
  214.          comments, please write to us or give us a call.
  215.  
  216.          If  you  are having a problem using LZW4C or any of our libraries,
  217.          call (205) 881-4630 between 5 PM  and  9  PM  CST  Monday  through
  218.          Friday.  You can call at other times and leave a message, and call
  219.          back  later during our regular business hours for a reply. You can
  220.          also FAX us at this same number at any time.
  221.  
  222.          You  may  also  call our 24 hour BBS (2400 baud, no parity, 8 data
  223.          bits, 1 stop bit) at any time.  The BBS will  contain  the  latest
  224.          shareware version of LZW4C, messages, and other related files. All
  225.          files  are  in standard ZIP format. You can leave a message on the
  226.          BBS, and we will usually have a reply  ready  for  you  within  24
  227.          hours.   The dedicated telephone number is 205-880-9748.  Set your
  228.          modem for 1200 to 9600 baud, 8 data bits, no parity, one stop bit.
  229.  
  230.          The  MarshallSoft  Computing,  Inc.   newsletter  "Comm  Talk"  is
  231.          published quarterly.  It discusses various communications problems
  232.          and  solutions using PCL4C (the communications library) as well as
  233.          related information such as data compression  issues.   Registered
  234.          users  receive  a  one  year complimentary subscription when first
  235.          registering and for each update purchased.   Additional  one  year
  236.          subscriptions  are  $15  plus $5 for overseas postage (postpaid in
  237.          US).
  238.  
  239.  
  240.         LZW4C Users Manual                                     Page 4
  241.          1.4 Installation
  242.  
  243.  
  244.          (1)  Microsoft C, Borland & Turbo C, and MIX Power C compilers are
  245.          supported. However, the code should work with most any C compiler.
  246.          Before installation of LZW4C, your C compiler  should  already  be
  247.          installed  on your system and tested. If you are not familiar with
  248.          makefiles, refer to your compiler manual. If  you  are  using  the
  249.          interactive environment for Quick C or Turbo C, be sure to compile
  250.          with the memory model corresponding to the LZW4C library used.
  251.  
  252.          (2) Make a backup  copy  of  your  distribution  disk.   Put  your
  253.          original distribution disk in a safe place.
  254.  
  255.          (3)  Create  a  work  directory  on  your work disk (normally your
  256.          harddisk). For example, to create a work directory named LZW4C, we
  257.          first log onto the work disk and then type:
  258.  
  259.                                MKDIR LZW4C
  260.  
  261.          (4)  Copy  all the files from your backup copy of the distribution
  262.          disk to your work directory.  For example, to  copy  from  the  A:
  263.          drive to your work directory, we type:
  264.  
  265.                               CD LZW4C
  266.                               COPY A:*.*
  267.  
  268.          (5) Compile COMPRESS.C, EXPAND.C, TEST_LZW.C  and  link  with  the
  269.          appropriate LZW4C library (they use the COMPACT library except for
  270.          MIX Power C). For example, to make COMPRESS.EXE:
  271.  
  272.              a) Borland Turbo C: Type
  273.  
  274.                   MAKE -FCOMPRESS._T_
  275.  
  276.              b) Microsoft C: Type
  277.  
  278.                   MAKE COMPRESS._M_
  279.  
  280.              c) MIX Power C: Type (LARGE model only)
  281.  
  282.                   X_COMPRESS
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.         LZW4C Users Manual                                     Page 5
  301.          2.0 The LZW Algorithm
  302.  
  303.  
  304.          The following discussion of the LZW algorithm is meant to  provide
  305.          a  high  level  overview  of  LZW.  For those interested in a more
  306.          detailed explanation, several good books  are  available  on  data
  307.          compression.
  308.  
  309.          The original research papers on what is now called LZW compression
  310.          are:
  311.  
  312.              J. ZIV and A. Lempel,
  313.              "A Universal Algorithm for Sequential Data Compression",
  314.              IEEE Transactions on Information Theory, May 1977.
  315.  
  316.              Terry Welch,
  317.              "A Technique for High-Performance Data Compression",
  318.               Computer, June 1984.
  319.  
  320.  
  321.          2.1 LZW Compression
  322.  
  323.  
  324.          The  LZW  compressor  reads  8-bit  bytes  from  a data source and
  325.          outputs N-bit codes each of which identifies a previously  defined
  326.          string.   The  value  of  N starts at 9. Thus, codes 0 through 255
  327.          (0xff) correspond with the standard character set, while codes 256
  328.          (0x100) through 511 (0x1ff) correspond to a byte-byte  pair  or  a
  329.          code-byte pair in the code table. After code 511 is output, 10 bit
  330.          codes  are used. This is repeated until the maximum number of bits
  331.          per code is reached (14 in the LZW4C library).
  332.  
  333.          The LZW compressor builds a code table as it compresses data.  The
  334.          code table consists of previously encountered strings.
  335.  
  336.          The basic LZW compression algorithm is as follows:
  337.  
  338.              STRING = get first input byte
  339.              while there is more input data
  340.                {BYTE = get next input byte
  341.                 if STRING+BYTE is in code table
  342.                    STRING=STRING+BYTE
  343.                 else
  344.                   {output code for STRING
  345.                    add STRING+BYTE to code table
  346.                    STRING = BYTE
  347.                   }
  348.               }
  349.              output the code for STRING
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.         LZW4C Users Manual                                     Page 6
  361.          2.2 LZW Expansion
  362.  
  363.  
  364.          The LZW expansion routine reads the N-bit codes previously created
  365.          by  the  LZW  compressor  and  reconstructs  the  code  table  (as
  366.          previously constructed by the compressor) as it is outputing 8-bit
  367.          bytes.  A code corresponds to a single byte (the first  256  codes
  368.          from 0x00 through 0xff), or a byte-byte pair in the code table, or
  369.          a  code-byte  pair  in the code table. In the later case, the code
  370.          part of the code-byte pair refers to another defined code pair  in
  371.          the  table.   As  each  code is read in, it is located in the code
  372.          table and the corresponding 8-bit bytes are  output.   This  means
  373.          that  codes  must be defined before they are needed for expansion.
  374.          Unlike  older  dictionary  based  compression  schemes,  the  code
  375.          dictionary  produced by the compressor routine does not have to be
  376.          provided to the expansion routine.
  377.  
  378.          The basic LZW de-compression algorithm is as follows:
  379.  
  380.              OLDCODE = input first code
  381.              output OLDCODE
  382.              while there is more input data
  383.                {NEWCODE = get next input code
  384.                 STRING = translation of NEWCODE
  385.                 output STRING
  386.                 BYTE = 1st byte of STRING
  387.                 add OLDCODE+BYTE to the code table
  388.                 OLDCODE = NEWCODE
  389.                }
  390.  
  391.          2.3 Implementation
  392.  
  393.  
  394.          The LZW4C library is written in assembly language.  Any  Microsoft
  395.          or  compatible assembler will assemble it. The decision to program
  396.          LZW4C in assembler was made in order to get the  absolute  maximum
  397.          performance  possible.  Although  optimized  C is very good, it is
  398.          still bigger and slower than hand optimized assembler.
  399.  
  400.          The LZW algorithm requires more temporary working data space  than
  401.          is  available  in  the  SMALL or MEDIUM memory models.  Therefore,
  402.          there are no SMALL or MEDIUM memory model libraries provided,  but
  403.          there  are  COMPACT  (lzw4c_c.lib)  and LARGE (lzw4c_l.lib) memory
  404.          model libraries.
  405.  
  406.          Use the COMPACT memory model when your code will fit into 64KB  or
  407.          less, otherwise you must use the LARGE memory model. Refer to your
  408.          compiler manual for a complete discussion of memory models.
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.         LZW4C Users Manual                                     Page 7
  421.          3.0 Example Programs
  422.  
  423.  
  424.          Five example programs are provided.  Each example  program  should
  425.          be  compiled  with  the provided makefile.  These example programs
  426.          are meant to demonstrate various ways in which the LZW compression
  427.          library can be used.
  428.  
  429.          If you are using an integrated  compiler  environment  instead  of
  430.          makefiles,  notice  that each program is compiled with the COMPACT
  431.          memory model.
  432.  
  433.  
  434.          3.1 COMPRESS
  435.  
  436.  
  437.          The  program  COMPRESS  is  provided  as  both  a  standalone  LZW
  438.          compression  program,  and  as  an example of how to use the LZW4C
  439.          library to compress a file. In order to run COMPRESS, type
  440.  
  441.              COMPRESS <infile> <outfile>
  442.  
  443.          For example, to compress LZW4C.DOC to LZW4C.LZW, type
  444.  
  445.              COMPRESS LZW4C.DOC LZW4C.LZW
  446.  
  447.  
  448.          3.2 EXPAND
  449.  
  450.  
  451.          The  program  EXPAND  is  provided  as  both  a   standalone   LZW
  452.          de-compression  program, and as an example of how to use the LZW4C
  453.          library to de-compress a file. In order to run EXPAND, type
  454.  
  455.              EXPAND <infile> <outfile>
  456.  
  457.          For example, to de-compress LZW4C.LZW to LZW4C.DOC, type
  458.  
  459.              COMPRESS LZW4C.LZW LZW4C.DOC
  460.  
  461.          Of course, you can only decompress a file that has been compressed
  462.          with COMPRESS.
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.         LZW4C Users Manual                                     Page 8
  481.          3.3 TEST_LZW
  482.  
  483.  
  484.          The program TEST_LZW is used to compress, expand, and  verify  one
  485.          or  more  files. It's purpose is for you to test the LZW4C library
  486.          on your own files.  Your files are never modified.   However,  you
  487.          can  NOT  specify  a file named "XXX.XXX" or "YYY.YYY" since these
  488.          files are work files used by  COMPRESS  and  EXPAND.   Compression
  489.          ratios  (  compressed_size  / original_size ) are printed for each
  490.          file compressed. For example, to test all files ending with a  *.C
  491.          extension:
  492.  
  493.              TEST_LZW *.C
  494.  
  495.          After compiling TEST_LZW, run it  against  a  large  directory  of
  496.          files as a test of the library.
  497.  
  498.  
  499.          3.4 MK_ARC
  500.  
  501.  
  502.          The program MK_ARC is used to create an archive file. For example,
  503.          to  create  an  archive named C.ARF consisting of all files ending
  504.          with the extension '.C', type:
  505.  
  506.              MK_ARC *.C C.ARF
  507.  
  508.  
  509.          3.5 UN_ARC
  510.  
  511.  
  512.          The program UN_ARC is used to un-archive  the  files  archived  by
  513.          MK_ARC. For example, to un-archive C.ARF, type:
  514.  
  515.              UN_ARC C.ARF
  516.  
  517.          Note  that  the  UN_ARC  program  can be modified to provide for a
  518.          customized product installation program.
  519.  
  520.          3.6 SEE_ARC
  521.  
  522.          The  program SEE_ARC is used to list the files in any archive file
  523.          created with MK_ARC. For example, to see the files in C.ARF:
  524.  
  525.              SEE_ARC C.ARF
  526.  
  527.          All example code should be compiled using the COMPACT memory model
  528.          (FAR data pointers, NEAR code pointers). You may  create  a  LARGE
  529.          memory model version of the above five programs by re-compiling as
  530.          LARGE memory model programs.
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.         LZW4C Users Manual                                     Page 9
  541.          4.0 Reader & Writer Functions
  542.  
  543.  
  544.          Both the compression and expansion routines in the  LZW4C  library
  545.          use  Reader  and  Writer functions supplied by the library caller.
  546.          They are provided as a means to give the caller  complete  control
  547.          over  the  source  and  destination  of  the  data  stream  during
  548.          compression and expansion.
  549.  
  550.          A reader function is not limited to reading from disk. It may read
  551.          from  any  data source as long as it returns a -1 when there is no
  552.          more data to be read. Similiarly, a writer function may  write  to
  553.          any data sink.
  554.  
  555.          A simple example of suitable reader and writer functions which can
  556.          be used to compress and expand files on disk are as follows:
  557.  
  558.              int Reader()
  559.              {
  560.               return(fgetc(FileInp));
  561.              }
  562.  
  563.              int Writer(Byte)
  564.              char Byte;
  565.              {
  566.               return(fputc(Byte,FileOut));
  567.              }
  568.  
  569.          where   FileInp   correspond  to  the  input  stream  and  FileOut
  570.          corresponds to the output stream:
  571.  
  572.              FILE *FileInp;
  573.              FILE *FileOut;
  574.  
  575.              FileInp = fopen(<input_file_name>,"rb");
  576.              FileOut = fopen(<output_file_name>,"wb");
  577.  
  578.          Note that the Reader returns a -1 for an end  of  data  condition.
  579.          Data is returned as an integer with the high byte set to 0.  Thus,
  580.          the  only  integers  can  can  be  returned  by  the Reader are -1
  581.          (0xffff) and 0 (0x0000) to 255 (0x00ff).
  582.  
  583.          If you remove data from a character buffer, be sure  to  zero  out
  584.          the  high  order byte (AND with 0x00ff) unless you are returning a
  585.          -1 (EOF).  For an example,  examine  the  code  for  the  Reader()
  586.          function in RW_IO.C.
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.         LZW4C Users Manual                                     Page 10
  601.          5.0 Library Functions
  602.  
  603.  
  604.          There are four functions in the LZW4C library as follows:
  605.  
  606.  
  607.          5.1 InitLZW
  608.  
  609.  
  610.          Function:     Initialize library
  611.  
  612.          Prototype:    int InitLZW(char *(*Alloc)() );
  613.  
  614.          Description:  The  InitLZW  function  is  used  to initialize  the
  615.                        library. The single argument is the function name of
  616.                        a user supplied memory allocation function.  Use  the
  617.                        standard C library function malloc() unless you wish
  618.                        to use your own memory management function.
  619.  
  620.          Returns:      -2 : (CANNOT_ALLOCATE) -- if unable to allocate.
  621.                         0 : (AOK) -- no error.
  622.  
  623.          Example:      /* initialize LZW4C */
  624.                        char *malloc();
  625.                        InitLZW(malloc);
  626.  
  627.  
  628.          5.2 TermLZW
  629.  
  630.  
  631.          Function:     Terminate library
  632.  
  633.          Prototype:    int TermLZW(int (*Free)() );
  634.  
  635.          Description:  The  TermLZW  function  is  used  to  terminate  the
  636.                        library after all processing is  done.   The  single
  637.                        argument  is  the  function  name of a user supplied
  638.                        memory de-allocation function.  This is primarily  a
  639.                        way   to   free memory allocated by InitLZW. Use the
  640.                        standard C library function free() unless  you  wish
  641.                        to use your own memory management free function.
  642.  
  643.          Returns:      0 : (AOK) -- no error.
  644.  
  645.          Example:      /* terminate LZW4C */
  646.  
  647.                        TermLZW(free);
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.         LZW4C Users Manual                                     Page 11
  661.          5.3 Compress
  662.  
  663.  
  664.          Function:     Compresses a data set.
  665.  
  666.          Prototype:    int Compress(Reader,Writer)
  667.                        int (*Reader)();     /* pointer to Reader() */
  668.                        int (*Writer)();     /* pointer to Writer() */
  669.  
  670.          Description:  The  Compress  function  is used to compress  a data
  671.                        set.  The Reader function always  returns  the  next
  672.                        input  byte.  The  Writer function consumes the next
  673.                        output byte. Refer to the section  on  Reader/Writer
  674.                        I/O.
  675.  
  676.          Returns:      -4 : (NOT_READY) -- Didn't call InitLZW() first.
  677.                         0 : (AOK) -- No error.
  678.  
  679.          Example:      /* compress a file */
  680.                        FILE *FileInp, *FileOut;
  681.                        FileInp = fopen("LZW4C.DOC","rb");
  682.                        FileOut = fopen("LZW4C.LZW","wb");
  683.                        Compress(Reader,Writer);
  684.  
  685.                        int Reader()
  686.                        {return(fgetc(FilePtr));}
  687.  
  688.                        int Writer(Byte)
  689.                        int Byte;
  690.                        {return(fputc(Byte,FilePtr));}
  691.  
  692.  
  693.          5.4 Expand
  694.  
  695.  
  696.          Function:     Expands a file.
  697.  
  698.          Prototype:    int Expand(Reader,Writer)
  699.                        int (*Reader)();     /* pointer to Reader() */
  700.                        int (*Writer)();     /* pointer to Writer() */
  701.  
  702.          Description:  The  Expand  function is used to de-compress  a file
  703.                        previously compressed with  the  Compress  function.
  704.                        The  Reader  function  always returns the next input
  705.                        byte.  The Writer function consumes the next  output
  706.                        byte.  Refer  to  the  section on Reader/Writer I/O.
  707.  
  708.          Returns:      -1 : (EXPANSION_ERROR)  -- File not compressed by
  709.                              the compress function.
  710.                         0 : (AOK) -- No error.
  711.  
  712.          Example:      /*  de-compress a file */
  713.                        FILE *FileInp, *FileOut;
  714.                        FileInp = fopen("LZW4C.DOC","rb");
  715.                        FileOut = fopen("LZW4C.LZW","wb");
  716.                        Expand(Reader,Writer);
  717.  
  718.  
  719.  
  720.         LZW4C Users Manual                                     Page 12
  721.          6.0 Error Codes
  722.  
  723.  
  724.          Be  sure and check the return codes from each LZW4C function call.
  725.          There are only 4 error codes returned by the LZW4C  library  other
  726.          than  0  (no  error). All error codes are negative numbers.  Their
  727.          numerical values are in the LZW4C.H file.
  728.  
  729.          Each error code is returned by a library function as follows:
  730.  
  731.          ****************************************************************
  732.          *    Error Name    *  IntLZW  *  TermLZW * Compress *  Expand  *
  733.          ****************************************************************
  734.          * EXPANSION_ERROR  *    No    *    No    *    No    *    Yes   *
  735.          * CANNOT_ALLOCATE  *    Yes   *    No    *    No    *    No    *
  736.          * INTERNAL_ERROR   *    Yes   *    No    *    No    *    No    *
  737.          * NOT_READY        *    No    *    No    *    Yes   *    Yes   *
  738.          ****************************************************************
  739.  
  740.  
  741.          6.1 EXPANSION_ERROR
  742.  
  743.  
  744.          An EXPANSION_ERROR error is returned only by the Expand()  library
  745.          function. It is caused by attempting to expand a file that was not
  746.          compressed   by  the  Compress()  function.  Note,  however,  that
  747.          Expand() may expand a file that was not compressed  by  Compress()
  748.          without returning an EXPANSION error.
  749.  
  750.  
  751.          6.2 CANNOT_ALLOCATE
  752.  
  753.  
  754.          A  CANNOT_ALLOCATE error is returned only by the InitLZW() library
  755.          function.  It is  caused  when  the  Alloc()  function  passed  to
  756.          InitLZW()  returns  a  NULL  pointer,  indicating  that  it cannot
  757.          allocate sufficient memory.
  758.  
  759.  
  760.          6.3 INTERNAL_ERROR
  761.  
  762.  
  763.          An INTERNAL_ERROR error is returned only by the InitLZW()  library
  764.          function  and  only  in  the  shareware  version.  It is caused by
  765.          modification of the Shareware screen. You should  never  get  this
  766.          error.
  767.  
  768.  
  769.          6.4 NOT_READY
  770.  
  771.  
  772.          A NOT_READY error is  returned  by  the  Compress()  and  Expand()
  773.          library  functions. It is caused by calling Compress() or Expand()
  774.          without first calling InitLZW().
  775.  
  776.  
  777.  
  778.  
  779.  
  780.         LZW4C Users Manual                                     Page 13
  781.          7.0 Legal Issues
  782.  
  783.          7.1 Registration
  784.  
  785.  
  786.          The shareware version  of  LZW4C  is  provided  so  that  you  may
  787.          personally  determine  the usefulness of the product for yourself.
  788.          If you can use the LZW4C Data Compression Library, please register
  789.          your use with us.  Send $35 plus  $3  S&H  ($6  outside  of  North
  790.          America) to:
  791.  
  792.                   MarshallSoft Computing, Inc.
  793.                   Post Office Box  4543
  794.                   Huntsville AL 35815
  795.  
  796.          We  accept  American  Express  (account  number,  expiration  date,
  797.          exact name on your  card,  and  AmEx  billing  address  required),
  798.          checks  in  US  dollars  drawn on a US bank, purchase orders (POs)
  799.          from  recognized  US  schools  and  companies  listed  in  Dun   &
  800.          Bradstreet,  and  COD  (street  address and phone number required)
  801.          within the USA (plus a $3 COD charge).  Print the  file  PCL4C.INV
  802.          if  an  invoice  is needed. The registered package is mailed first
  803.          class US Mail (packet air mail overseas).
  804.  
  805.  
  806.          Print the file LZW4C.INV if an invoice is needed.  The  registered
  807.          package is mailed first class US Mail (packet air mail overseas).
  808.  
  809.          The registered package includes:
  810.  
  811.          o  No shareware screen.
  812.          o  Assembler source code for the library.
  813.          o  Laser printed Users Manual.
  814.          o  Telephone / FAX / BBS  support for one year.
  815.          o  One year subscription (quarterly) to MSC newsletter.
  816.             (requires extra $5 postage if overseas)
  817.          o  All updates (with printed manuals) are $15  plus  $3  S&H
  818.             ($6 outside of North America).
  819.  
  820.          LZW4C.ASM is the source code for the library. The source  code  is
  821.          copyrighted  by MarshallSoft Computing, Inc. The user is granted a
  822.          license to use the LZW4C object code in his own application  only.
  823.          LZW4C.ASM  is  not  shareware and may not be sold or given away to
  824.          anyone.
  825.  
  826.          The registered user will receive the latest version  of  LZW4C  by
  827.          return  mail.  A 5.25" diskette is provided unless a 3.5" diskette
  828.          is requested.
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.         LZW4C Users Manual                                     Page 14
  841.          7.2 License
  842.  
  843.  
  844.          MarshallSoft Computing, Inc. grants the registered user  of  LZW4C
  845.          the  right  to  use  the  LZW4C  library  (in  object form) in the
  846.          development  of  any  software  product  without  any   royalties.
  847.          However,  the  source  code for the library may not be released in
  848.          whole or in part.
  849.  
  850.  
  851.          7.3 Warranty
  852.  
  853.  
  854.          MARSHALLSOFT COMPUTING, INC. DISCLAIMS ALL WARRANTIES RELATING  TO
  855.          THIS  SOFTWARE,  WHETHER  EXPRESSED  OR IMPLIED, INCLUDING BUT NOT
  856.          LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY  AND  FITNESS
  857.          FOR  A  PARTICULAR  PURPOSE, AND ALL SUCH WARRANTIES ARE EXPRESSLY
  858.          AND SPECIFICALLY DISCLAIMED. NEITHER MARSHALLSOFT COMPUTING,  INC.
  859.          NOR ANYONE ELSE WHO HAS BEEN INVOLVED IN THE CREATION, PRODUCTION,
  860.          OR  DELIVERY  OF  THIS  SOFTWARE SHALL BE LIABLE FOR ANY INDIRECT,
  861.  
  862.          CONSEQUENTIAL, OR INCIDENTAL DAMAGES ARISING OUT  OF  THE  USE  OR
  863.          INABILITY  TO  USE  SUCH  SOFTWARE EVEN IF MARSHALLSOFT COMPUTING,
  864.          INC.  HAS BEEN ADVISED OF  THE  POSSIBILITY  OF  SUCH  DAMAGES  OR
  865.          CLAIMS. IN NO EVENT SHALL MARSHALLSOFT COMPUTING, INC.'S LIABILITY
  866.          FOR ANY SUCH DAMAGES EVER EXCEED THE PRICE PAID FOR THE LICENSE TO
  867.          USE  THE SOFTWARE, REGARDLESS OF THE FORM OF THE CLAIM. THE PERSON
  868.          USING  THE  SOFTWARE  BEARS  ALL  RISK  AS  TO  THE  QUALITY   AND
  869.          PERFORMANCE OF THE SOFTWARE.
  870.  
  871.          Some  states  do not allow the exclusion of the limit of liability
  872.          for consequential or incidental damages, so the  above  limitation
  873.          may not apply to you.
  874.  
  875.          This  agreement  shall  be  governed  by  the laws of the State of
  876.          Alabama and shall inure to the benefit of Marshallsoft  Computing,
  877.          Inc.   and  any successors, administrators, heirs and assigns. Any
  878.          action or proceeding brought by either  party  against  the  other
  879.          arising  out of or related to this agreement shall be brought only
  880.          in a STATE or FEDERAL COURT of competent jurisdiction  located  in
  881.          Madison County, Alabama. The parties hereby consent to in personam
  882.          jurisdiction of said courts.
  883.  
  884.  
  885.          8.0 Revision History
  886.  
  887.  
  888.          Version 1.0 -- October 8, 1992 -- original release.
  889.  
  890.          Version 1.1 -- November 11, 1992
  891.  
  892.          o Added MK_ARC and UN_ARC example programs.
  893.  
  894.          Version 1.2 -- March 1, 1993
  895.  
  896.          o  Added SEE_ARC example program.
  897.          o  Minor speed improvements.
  898.  
  899.  
  900.         LZW4C Users Manual                                     Page 15
  901.          9.0 Other MarshallSoft Computing Products for C
  902.  
  903.  
  904.          Shareware  versions  of  all  MarshallSoft  Computing products are
  905.          available on our user support BBS 205-880-9748.
  906.  
  907.  
  908.          9.1 The Personal Communications Library for C
  909.  
  910.  
  911.          The Personal Communications Library for the C Language (PCL4C)  is
  912.          an  asynchronous  communications  library designed for experienced
  913.          software  developers  programming  in  C.   Four   compilers   are
  914.          supported:  Microsoft  Optimizing  C,  Microsoft  Quick C, Borland
  915.          Turbo C, and MIX Power  C.   An  IBM  PC/XT/AT  or  compatible  is
  916.          required.  The PCL features:
  917.  
  918.          o SMALL, COMPACT, MEDIUM & LARGE memory models.
  919.          o 32 communications and support functions.
  920.          o Support for the high performance INS16550 UART.
  921.          o Supports hardware (RTS/CTS) flow control.
  922.          o Interrupt driven receiver.
  923.          o Supports 300 baud to 115,200 baud.
  924.          o Supports COM1, COM2, COM3, and  COM4.
  925.          o Adjustable receive queues from 8 bytes to 32 KB.
  926.          o Control-BREAK error exit.
  927.          o 17 communications error conditions trapped.
  928.          o Allows 4 ports to run concurrently.
  929.          o Complete modem control & status.
  930.          o Written in assembly language for small size & high speed.
  931.          o Terminal program featuring XMODEM, YMODEM, & YMODEM-G.
  932.  
  933.          The Personal Communications Library for C (PCL4C) is available for
  934.          $55  plus  $3 S&H ($6 S&H overseas). It may be ordered at the same
  935.          time as the Personal Protocol Library for $65 plus $3.50  S&H  ($7
  936.          overseas).
  937.  
  938.  
  939.          9.2 The Personal Protocol Library for C
  940.  
  941.  
  942.          The  Personal  Protocol  Library  (PPL)  consist of a state driven
  943.          library  which  implements  the  XMODEM,  XMODEM-CRC,   XMODEM-1K,
  944.          XMODEM-G,  YMODEM,  and  YMODEM-G  file  transfer protocols.  This
  945.          allows  the  programmer  to  run   multiple   protocol   transfers
  946.          simultaneously while interacting with the user at the keyboard.
  947.  
  948.          The  Personal  Protocol Library for C (PPL4C) is available for $35
  949.          plus $3 S&H ($6 S&H overseas). Both the Communications library and
  950.          the Protocol library can be ordered together for $65.
  951.  
  952.          The PPL requires the Personal Protocol Library for  C  (PCL4C)  as
  953.          described above.
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.         LZW4C Users Manual                                     Page 16
  961.